package com.rz.admin.controller;


import com.rz.admin.entity.SysDictData;
import com.rz.admin.service.impl.SysDictDataServiceImpl;
import com.rz.core.kit.RespKit;
import com.rz.core.resp.ResultResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Rui.Zhou
 * @since 2018-07-12
 */
@RestController
@RequestMapping("/sysDictData")
public class SysDictDataController {

    @Autowired
    private SysDictDataServiceImpl sysDictDataService;

    @PostMapping("getForSelect/{dictValue}")
    public ResultResp getForSelect(@PathVariable String dictValue){
        return RespKit.success(sysDictDataService.getByDictValue(dictValue));
    }

    @PostMapping("getPage")
    public ResultResp getPage(@RequestBody SysDictData sysDictData){
        return RespKit.success(sysDictDataService.getPage(sysDictData));
    }

    @PostMapping("save")
    public ResultResp save(@RequestBody SysDictData sysDictData){
        return RespKit.success(sysDictDataService.saveDictData(sysDictData));
    }

    @PostMapping("delete/{id}")
    public ResultResp delete(@PathVariable Integer id){
        return RespKit.success(sysDictDataService.removeById(id));
    }
}

